<template>
  <div class="home-banner">
    <Slider :data="banList" autoPlay />
  </div>
</template>

<script>
import { findBanner } from '@/api/home'
import { ref, onMounted } from 'vue'

// 可以单独抽成个hook
const useSlider = () => {
  const banList = ref([])

  onMounted(() => {
    getBanList()
  })

  // getList() // 这里发也可以

  async function getBanList () {
    const { result } = await findBanner()
    // console.log('轮播图列表: ', result)
    banList.value = result
  }

  return { banList }
}
export default {
  name: 'HomeBanner',
  setup () {
    const { banList } = useSlider()
    return { banList }
  }
}
</script>

<style scoped lang='less'>
.home-banner {
  width: 1240px;
  height: 500px;
  position: absolute;
  left: 0;
  top: 0;
  z-index: 98;
}
</style>
